let userService = require('../service/userService');
module.exports = {
    login : async function(ctx){
        console.log('ctx===>',ctx.request.body);
        let { account,password } = ctx.request.body;
        if(!account || !password){
            ctx.body = {
                code:-1,
                msg:'账号密码或者密码不能为空'
            };
        }
        let  res = await userService.login(account,password);
        ctx.body = res;
    },
    register : async function(ctx){
        console.log('ctx.body====>',ctx.request.body);
        let { account,password } = ctx.request.body;
        if(!account || !password){
            ctx.body = {
                code:-1,
                msg:'账号密码或者密码不能为空'
            };
        }
        console.log('ctx',ctx);
        let ip = '127.0.0.1';
        let  res = await userService.register(account,password,ip);
        console.log('data===>',res);
        ctx.body = res;
    },
    getName : async function(ctx){
        console.log('ctx.getName====>',ctx.query);
        ctx.body = ctx.query;
    },
}